package com.axend.aerosense.home.adapter;

import android.widget.ImageView;

import androidx.fragment.app.Fragment;

import com.axend.aerosense.home.entity.BannerBean;
import com.bumptech.glide.Glide;
import com.axend.aerosense.home.R;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;

public class BannerAdapter<T> extends BaseBannerAdapter<BannerBean> {
    private Fragment fragment;
    private IOnItemClick<T> iOnItemClick;

    public BannerAdapter(Fragment fragment, IOnItemClick iOnItemClick) {
        this.fragment = fragment;
        this.iOnItemClick = iOnItemClick;
    }

    @Override
    protected void bindData(BaseViewHolder<BannerBean> holder, BannerBean data, int position, int pageSize) {
        ImageView imageView = holder.itemView.findViewById(R.id.home_banner_image);
        Glide.with(fragment).load(data.getImg()).into(imageView);
        imageView.setOnClickListener(v->{
            iOnItemClick.onClick((T)data.getSrc());
        });
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.home_banner_item;
    }

}
